Python: Learn Python in One Week by Kilber Stewart

Python: Learn Python in One Week by Kilber Stewart

Author:Kilber Stewart [Stewart, Kilber]
Language: eng
Format: azw3, epub
Published: 2020-09-10T16:00:00+00:00


Type Casting

Sometimes we need to convert from one data type to another. This is known as type casting.

To perform type casting, Python has three built-in functions (we will learn about functions in a later chapter). These are int(), float(), and str() functions.

The int() function takes in a float or a string and converts it to an integer. To change a float to an integer, simply type int(6.764543). We will get6 as a result as you can see anything after the decimal point is removed. To change a string to an integer, we will type int(“4”), and we will get 4 as an output.

The float() function takes an integer or a string and converts it to a float. For example, if we type float(5) or float(“5”), we will get 5.0 as an output. If we type float(“5.72486”) we will get 5.72486 as an output. As you can see, the quotations marks are removed; hence it is converted into a float.

The str() function converts an integer or float to a string. For example, if we type str(5.2), we will get “5.2” as output.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(55934)
What's Done in Darkness by Kayla Perrin(26538)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19016)
The Fifty Shades Trilogy & Grey by E L James(18971)
Shot Through the Heart by Mercy Celeste(18890)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(16995)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16894)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16817)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16711)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16339)
The Subtle Art of Not Giving a F*ck by Mark Manson(14278)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14083)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13447)
Scorched Earth by Nick Kyme(12721)
Drei Generationen auf dem Jakobsweg by Stein Pia(10928)
Suna by Ziefle Pia(10852)
Scythe by Neal Shusterman(10283)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9486)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9331)
This is Going to Hurt by Adam Kay(9114)